import java.util.Scanner;
import java.util.Stack;

/**
 * 描述
 *
 * 输入一个表达式（用字符串表示），求这个表达式的值。
 * 保证字符串中的有效字符包括[‘0’-‘9’],‘+’,‘-’, ‘*’,‘/’ ,‘(’， ‘)’,‘[’, ‘]’,‘{’ ,‘}’。且表达式一定合法
 */
public class HJ54 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String expr = scanner.nextLine();
            expr = expr.replace("{", "(");
            expr = expr.replace("[", "(");
            expr = expr.replace("}", ")");
            expr = expr.replace("]", ")");
            System.out.println(cal(expr));
        }
    }

    private static int cal(String expr) {
        Stack<Integer> stack = new Stack<>();
        int num = 0;
        char sign = '+';
        for (int i = 0; i < expr.length(); i++) {
            char c = expr.charAt(i);
            if(c == ' ') continue;

            if(Character.isDigit(c)){
                num = num*10+c-'0';
            }
            if(c == '('){
                int j = i+1;
                int count = 1;
                while (count > 0){
                    if(expr.charAt(j) == ')') count--;
                    if(expr.charAt(j) == '(') count++;
                    j++;
                }
                num = cal(expr.substring(i+1,j-1));
                i = j - 1;
            }

            if(!Character.isDigit(c) || i==expr.length()-1){
                if(sign == '+'){
                    stack.push(num);
                }else if(sign == '-'){
                    stack.push(-1*num);
                } else if (sign == '*') {
                    stack.push(stack.pop()*num);
                }else if(sign == '/'){
                    stack.push(stack.pop()/num);
                }
                num = 0;
                sign = c;
            }
        }

        int res = 0;
        while (!stack.isEmpty()){
            res+=stack.pop();
        }
        return res;
    }

}
